package view;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.border.EmptyBorder;

import java.awt.Dimension;
import java.awt.Font;
import javax.swing.JButton;

import model.WoodList;
import javax.swing.JLabel;

	/*Mainframe esta compuesto de tres paneles
	 * top: contiene label con el nombre de la empresa.
	 * center: contiene un "orderpanel" que se crea dinamicamente 
	 * 		   segun los tipos de madera pasados por el modelo.
	 * bottom: contiene el boton de generacion de orden.
	 * */

public class MainFrame extends JFrame {

	private JPanel contentPane;
	public OrderPanel orderPanel;
	public JButton orderButton;

	public MainFrame(WoodList woodList) {

		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);
		
		//borderLayout -> top:
		JLabel veluvana_lbl = new JLabel("VeLuvana Inc.");
		veluvana_lbl.setHorizontalAlignment(SwingConstants.CENTER);
		veluvana_lbl.setFont(new Font("Tahoma", Font.PLAIN, 28));
		contentPane.add(veluvana_lbl, BorderLayout.NORTH);
		
		//borderLayout -> center:
		//add an orderpanel instance
		orderPanel = new OrderPanel( woodList.getWoodList() );
		getContentPane().add(orderPanel, BorderLayout.CENTER);
		
		//borderLayout -> south:
		JPanel buttonPanel = new JPanel();
		contentPane.add(buttonPanel, BorderLayout.SOUTH);
		orderButton = new JButton("Order");
		buttonPanel.add(orderButton);
		
		//adjust preferred size:
		setMinimumSize(getPreferredSize());
		setSize(getPreferredSize());
		doLayout();
	}

}
